package com.zggk.iroad.handle.handlelist;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.zggk.iroad.api.MyAppliCation;
import com.zggk.iroad.api.Urls;
import com.zggk.iroad.mvp.BasePresenterImpl;

import java.util.List;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class HandleListPresenter extends BasePresenterImpl<HandleListContract.View> implements HandleListContract.Presenter{
    @Override
    public void testinfo() {
        OkGo.<String>get(Urls.YNIP + "QueryYhwx_YN")
                .params("gydwid",MyAppliCation.spUtils.getString("GydwId"))
                .params("dataid","0")
                .params("action", "0")
                .params("pageSize", "50")
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        HandleListBean handleListBean = JSON.parseObject(response.body(), HandleListBean.class);
                        if (mView == null)
                            return;
                        if (handleListBean.getState().equals("1")) {
                            List<HandleBean> mainDclxInfo = JSON.parseArray(handleListBean.getWXMXTREE(), HandleBean.class);
                            mView.getDatas(mainDclxInfo);
                        }
                    }
                });

    }
    @Override
    public void deleteById(String guid) {
        OkGo.<String>post(Urls.YNIP + "DeleteBH")
                .params("BHID", guid)
                .execute(new StringCallback(){
                    @Override
                    public void onSuccess(Response<String> response) {
                        mView.deleteByIds();
                    }
                });
    }
}
